package org.opens.db.column.service;

import org.opens.db.column.service.impl.IDbInfoServiceOfMysql;
import org.opens.db.column.service.impl.IDbInfoServiceOfOracle;
import org.opens.db.constant.DbType;

import java.util.EnumMap;
import java.util.Map;

public class DbInfoServiceFactory {

    /**
     * 模拟spring容器
     */
    private static final Map<DbType, I_DbInfoService> COLUMN_SERVICE_MAP = new EnumMap<>(DbType.class);

    static {
        COLUMN_SERVICE_MAP.put(DbType.MYSQL, new IDbInfoServiceOfMysql());
        COLUMN_SERVICE_MAP.put(DbType.ORACLE, new IDbInfoServiceOfOracle());
    }

    /**
     * 根据数据库类型获取service实现类
     * @param dbType 数据库类型
     */
    public static I_DbInfoService getColumnServiceInstance(DbType dbType) {
        return COLUMN_SERVICE_MAP.get(dbType);
    }

}
